require(['./config'],()=>{
    require(['jquery','cookie'], ($) => {
        $('.header-container').load('./header.html')
        
    let user = document.querySelector('input[type=text]')
    let pass = document.querySelector('input[type=password]')
    let btn = document.querySelector('input[type=button]')
    let ckd = document.querySelector('input[type=checkbox]')
    btn.onclick =function(){
        let user1= user.value
        let pass1 = pass.value
        if(user1 == '' || pass1 == ''){
            alert('请输入账号或密码')
            return
        }else{
            let phone = /^1\d{10}$/
            if(!phone.test(user1)){
                alert('手机号码式不正确')
                return
            }
            let mima=  /^.{6,}$/
            if(!mima.test(pass1)){
                alert('请输入6-12位的密码')
                return
            }
            let user = JSON.parse(localStorage.getItem('userInfo')) || []
            let obj = {}
            obj.name= user1
            obj.password = pass1
            // console.log(obj);
            if(user.some((item)=>{return item.name === obj.name})){
                alert('用户名已存在')
                return
            }else{
                user.push(obj)
                localStorage.setItem('userInfo',JSON.stringify(user))
                alert('注册成功')
                location.href = '../html/login.html'
            }
        }
    }
    })
})
    
    
